package com.ash.test.beanfactory;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ash.bean.Car;

public class MySpringTestBeanFactory {

	@Test
	public void test() {
		// 使用"spring.xml"和"spring-mybatis.xml"这两个配置文件创建Spring上下文
		ApplicationContext ac = new ClassPathXmlApplicationContext(new String[] { "beans-factory.xml" });

		// 静态工厂方法
		Car car = (Car) ac.getBean("car1");
		System.out.println(car);

		// 实例工厂方法
		car = (Car) ac.getBean("car2");
		System.out.println(car);

        Object carFactoryBean = ac.getBean("car");
        System.out.println(carFactoryBean);

    }

}
